Skip to content

fix: read x402 payment response header - #15

Open
peterxing wants to merge 1 commit into
HathorNetwork:feat/x402-pocfrom
peterxing:fix/issue-3-payment-response
Open

fix: read x402 payment response header#15
peterxing wants to merge 1 commit into
HathorNetwork:feat/x402-pocfrom
peterxing:fix/issue-3-payment-response

Conversation

@peterxing

@peterxing peterxing commented May 21, 2026

Copy link
Copy Markdown

Summary

  • decode the x402 v2 PAYMENT-RESPONSE header on successful paid responses in the browser dApp
  • fall back to the existing JSON body payment object for compatibility
  • teach the Node demo client to read/log the settlement response from the header too

Why

Issue #3 calls out that the spec-compliant settlement channel is the PAYMENT-RESPONSE HTTP header. The resource server on the current POC branch already emits it; this patch makes both example clients consume it instead of relying only on the convenience JSON body.

Verification

  • git diff --check
  • node --check client.js
  • local Base64 payment-response decode smoke: PAYMENT_RESPONSE_DECODE_OK
  • npm run lint --prefix dapp -- --file components/X402Fetch.tsx
  • npm run build --prefix dapp

Note: direct tsc --noEmit -p dapp/tsconfig.json is currently blocked by pre-existing test/mock type errors outside this patch (dapp/__mocks__/hathorCoreAPI.ts, dapp/__tests__/unit/hathorRPC.test.ts, etc.). The Next production build passed.

Refs #3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant